#include "MarsPrecompile.h"

#include "MarsPipelineMgr.h"
#include "MarsFbxMgr.h"

using namespace Pipeline;

PipelineMgr* PipelineMgr::ms_pPipelineMgr = 0;

void PipelineMgr::Destroy()
{
	SAFE_DELETE( ms_pPipelineMgr );
}

PipelineMgr::PipelineMgr()
{

}

PipelineMgr::~PipelineMgr()
{
	Shutdown();
}

bool PipelineMgr::Initialize()
{
	if ( !FbxMgr::Instance().Initialize() )
	{
		return false;
	}

	FbxMgr::Instance().PostInit();

	return true;
}

void PipelineMgr::Shutdown()
{
	FbxMgr::Destroy();
}

void PipelineMgr::RegisterMeshImportMgr( MeshImportMgr* pMeshImportMgr )
{
	m_mapMeshImportMgrs[ pMeshImportMgr->GetMeshImportType() ] = pMeshImportMgr;
}

void PipelineMgr::UnRegisterMeshImportMgr( MeshImportType eMeshType )
{
	MeshImportMgrMapItr it = m_mapMeshImportMgrs.find( eMeshType );
	if ( it == m_mapMeshImportMgrs.end() )
		return;

	m_mapMeshImportMgrs.erase( it );
}

MeshImporter* PipelineMgr::GetMeshImporter( MeshImportType eMeshType )
{
	MeshImportMgrMapItr it = m_mapMeshImportMgrs.find( eMeshType );
	if ( it == m_mapMeshImportMgrs.end() )
		return NULL;

	return ( &it->second->GetMeshImporter() );
}
